5.6. Main Module

It is the module that contains the main() function. First must go header files (sect.5.2). Then if you have not included object code of EGAVGA.BGI into your project or GRAPHICS.LIB, include the line:

 int far EGAVGA_driver_far[1];

Next goes the declarations of global pointers (sect.5.3).
After that you would like to write the Background Procedure.

The main function starts with the initialization of Virtual Panels:

main()
{
InitAndCopyright("Copyright (c) O.Rasizade, 1992");
butsystem bsMain(MASTER); // bsMain button system is the master
                          // of Dragging area
// Next go declarations of Objects to be controlled by bsMain
button
// system. The object may be declared by two ways. One way
is to
// allocate the Object in the stack declaring:

Indicator<float>
  indTemperature        //-- TEMPERATURE INDICATOR
       ( 0, 0, PERM, "Temperature", 10, &Temp,"%.2fK");
   // here the global pointer is initialized
pindTemperature = &indTemperature;

// The other way is to allocate the Object in the heap:
pindTemperature = new Indicator<float>
                  ( 0, 0, PERM, "Temperature",10, &Temp,"%.2fK");
// In this case don't forget to delete the instanse:
// delete pindTemperature;

// After declarations of Objects it is reasonable to declare
// button groups:
butgrp HorizButtons(3,maxy-25,70,21,HORIZ,2);
 button butQuit("Quit",'Q','q',bpQuit,0,1,quittexcol,quitbutcol);
 button butHelp("Help",'h','H',bpHelp);
 .
 .
 button butTdep("T-dep",'T','t',bpTdep);
 button butTdepGraph("gRaph",'R','r',bpTdepGraph);

// Now paint panels, FIXED Objects and buttons:
 .
 .
 HorizButtons.Paint();

// At last is the program itself:
                //---------- PROGRAM ---------
 InitCamac();   // initialization procedures
 InitLabTask();
 camEnInt();
 .
 .
 object::LoadCnfg(CNF_NAME);   // restore configuration
 object::RepaintScr();  // and paint PERM Objects as they
                        // were disposed in the last session
 bsMain.NextButton();   // light on the first button
 bsMain.Loop(MainBackgr);// activate main button system

 object::SaveCnfg(CNF_NAME);   // save configuration
 QuitVirtualPanels();
}// end of main()

Note that the best way is to define starting coordinates of PERM and POPUP Objects in the upper left corner of the Dragging area. If you define them otherwise there is the chance that the disposition of the PERM and POPUP Objects well suited for the the VGA high resolution mode will ruin the screen when used in the EGA mode. That is because the difference in sizes of fonts is not compensated. So it is a good idea to dispose Objects from console what may be then saved by the object::SaveCnfg function.